package com.guli.order.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.ApiOperation;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.guli.order.entity.OrderReturnApplyEntity;
import com.guli.order.service.OrderReturnApplyService;

import com.guli.common.utils.R;


/**
 * 订单退货申请
 *
 * @author 罗俊华
 * @email 1007052116@qq.com
 * @date 2020-11-19 17:11:21
 */
@RestController
@RequestMapping("/order/orderreturnapply")
public class OrderReturnApplyController {

    @Autowired
    private OrderReturnApplyService orderReturnApplyService;


    @GetMapping("/list/{currentPage}/{size}")
    @ApiOperation("根据当前页和每页显示的记录数来获取orderReturnApply分页列表")
    public R list(@PathVariable("currentPage") Integer currentPage, @PathVariable("size") Integer size, @RequestParam Map<String, Object> params) {

        Page<OrderReturnApplyEntity> page = orderReturnApplyService.queryPage(currentPage, size, params);

        return R.ok().put("page", page);
    }


    @GetMapping("/info/{id}")
    @ApiOperation("根据id获取OrderReturnApply")
    public R info(@PathVariable("id") Long id) {

        OrderReturnApplyEntity orderReturnApply = orderReturnApplyService.getById(id);

        return R.ok().put("orderReturnApply", orderReturnApply);
    }

    @PostMapping("/save")
    @ApiOperation("插入OrderReturnApply")
    public R save(@RequestBody OrderReturnApplyEntity orderReturnApply) {

        orderReturnApplyService.save(orderReturnApply);

        return R.ok();
    }

    @PostMapping("/update")
    @ApiOperation("根据id更新OrderReturnApply")
    public R update(@RequestBody OrderReturnApplyEntity orderReturnApply) {
            orderReturnApplyService.updateById(orderReturnApply);

        return R.ok();
    }

    @PutMapping("/deleteBatch")
    @ApiOperation("根据id批量删除OrderReturnApply")
    public R delete(@RequestBody Long[] ids) {
            orderReturnApplyService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
